﻿#ifndef U_TDialog_H
#define U_TDialog_H

#if defined(_MSC_VER) && (_MSC_VER >= 1600)
# pragma execution_character_set("utf-8")
#endif

#include <QDialog>
#include <QLabel>
#include <QPushButton>
#include <QToolButton>
#include <QGroupBox>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGridLayout>

#include <QMouseEvent>
#include <QPaintEvent>
#include <QPainter>

class TDialog : public QDialog
{
    Q_OBJECT
public:
    explicit TDialog(QWidget *parent = nullptr);
    ~TDialog();

    void setMaxHide();
    void setTitle(QString title);
    void addLayout(QLayout *);
    void addWidget(QWidget *);

protected:
    bool eventFilter(QObject *obj, QEvent *event);
    void mouseMoveEvent(QMouseEvent *e);
    void mousePressEvent(QMouseEvent *e);
    void mouseReleaseEvent(QMouseEvent *);

signals:

public slots:
    void OnBtnMenuCloseClicked();
    void OnBtnMenuMaxClicked();
    void OnBtnMenuMinClicked();

private:
    void InitTitle();

    bool    max;
    bool    mousePressed;            //鼠标是否按下
    QPoint  mousePoint;              //鼠标拖动自定义标题栏时的坐标

    QLabel  *labIco;
    QLabel  *labTitle;

    QPushButton *butMenuMin;
    QPushButton *butMenuMax;
    QPushButton *butMenuClose;

    QVBoxLayout *mainLayout;
};

#endif // U_TDialog_H
